package demo4;

import java.util.Arrays;
import java.util.Random;
import java.util.Scanner;
import java.util.UUID;

/**
 * Author：毕龙
 * Date: 2024/5/15 20:07
 */
public class TestStringMethod2 {
    public static void main(String[] args) {
        String str = "  雷小华穆龙龙王伟樊子枭郑泽豪  ";
        System.out.println(str);
        String trim = str.trim();
        System.out.println(trim);
        String intern = str.intern();
        System.out.println(intern);

        String s1 = new String("abc");
        System.out.println(System.identityHashCode(s1));
        String s2 = "abc";
        System.out.println(s1 == s2);//false
        System.out.println(System.identityHashCode(s2));
        s1 = s1.intern();//获取串池中的字符串
        System.out.println(System.identityHashCode(s1));
        System.out.println(s1 == s2);//true

        String s = s1.substring(1);
        System.out.println(s);
        s = s1.substring(1,2);
        System.out.println(s);

        //在开发中使用  .png  在生一个文件
        String name = "mulong.png";
        int index = name.lastIndexOf('.');
        String suffixName = name.substring(index);
        String string = UUID.randomUUID().toString();

        String[] split = string.split("-");
        System.out.println(Arrays.toString(split));

        String replace = string.replace("-", "");
        System.out.println(string.replace("-", ""));
        String newName = replace+suffixName;
        System.out.println(newName);
        boolean txt = name.endsWith("txt");
        System.out.println(txt);


    }
}
